﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace MenuGame2DXNA
{
    public class TimeCount : TextEntity
    {
        int Time;
        int timeStart;

        public TimeCount(ContentManager content, int time, GameTime gameTime, string _format = "00")
            : base(content)
        {
            timeStart = (int)gameTime.TotalGameTime.TotalMilliseconds;
            Time = time;
            FormatString = _format;
           
        }
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Color color)
        {
            int countDown = Time -((int)gameTime.TotalGameTime.TotalMilliseconds - timeStart) / 1000;
            if (countDown < 0)
                countDown = 0;
            Text = countDown.ToString(FormatString);
        }
    }
}
